const { override, adjustStyleLoaders, addWebpackAlias, addLessLoader, fixBabelImports } = require('customize-cra')
const path = require('path')
const antVariables = require('./src/lib/ant-variables')

module.exports = override(
    addLessLoader({
        // lessOptions: {
        javascriptEnabled: true,
        modifyVars: antVariables
        // }
    }),
    fixBabelImports('import', {
        libraryName: 'antd',
        style: true
    }),
    adjustStyleLoaders((rule) => {
        if (rule.test.toString().includes('scss')) {
            rule.use.push({
                loader: require.resolve('sass-resources-loader'),
                options: {
                    //这里是你自己放公共scss变量的路径
                    resources: [path.resolve(__dirname, './src/scss/settings/variables.module.scss')]
                }
            })
        }
    }),
    addWebpackAlias({
        '@': path.resolve(__dirname, './src'),
        '@styles': path.resolve(__dirname, './src/assets/styles'),
        '@images': path.resolve(__dirname, './src/assets/images')
    })
)
